/*
 *  $TEAM_NAME Space Trader
 */
package presenters;

import models.Player;
import models.Marketplace;
import models.Ship;

import views.PrettyMarketPanel;

import java.util.Observer;
import java.util.Observable;

/**
 * Shows the market table with a cell for each good
 * @author twb
 * @version 1.0
 */
public class PrettyMarketPresenter
extends Presenter<PrettyMarketPanel> implements Observer {
	/**
	 * field
	 */
	private final Player player;

	/**
	 * field
	 */
	private Marketplace marketplace;
    
	/**
	 * field
	 */
	private Ship ship;
	
	/**
	 * pretty market panel
	 * @param player
	 * @param view
	 */
	public PrettyMarketPresenter(Player player, PrettyMarketPanel view) {
        this.marketplace = player.getLocation().getMarketplace(); 
        this.ship = player.getShip();
        this.player = player;

        super.setView(view); 

        player.addObserver(this);
        ship.addObserver(this);
        marketplace.addObserver(this);
    }

	/**
	 * update
	 * @param o
	 * @param arg
	 */
    public void update(Observable o, Object arg) {
        if (o.equals(player)) {
            marketplace = player.getLocation().getMarketplace();
            ship = player.getShip();
        }

        view.update();
    }
    
    /**
     * to string
     * @return string
     */
    public String toString() {
		return "";
	}
}
